Skip to content

cmake: function-visibility.txt entries for the /GL units of #515, #516 and #518 - #534

Merged
gynt merged 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/units-A-visibility-100
Nov 30, 2026
Merged

gynt merged 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/units-A-visibility-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

#515, #516 and #518 put twelve Map::Units update functions on cmake/compiler-flags-gl.txt, each at 100% in the default build. Three of them (UpdateCamel, UpdateLady, UpdateFireEater) already have an entry in cmake/function-visibility.txt and read 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on. The other nine have none, and each of those PRs left their entries for a follow-up with its own full build in that mode. This is that follow-up: one commit, cmake/function-visibility.txt only, an entry for each of the nine at its address, its callees in address order. No .cpp, header or /GL change.

Function Address PR Option on, before -> after Callees named
Units::UpdateMother 0x00546BC0 #515 52.9% / 49.4% -> 100.0% / 100.0% checkIfCitizenUnitIsAliveBasedOnState, hasUnitReachedDestination, changeDestinationByAmount
Units::UpdateChild 0x005477C0 #516 47.3% / 46.5% -> 100.0% / 100.0% the same three and hasTunnelerNotFinishedDigging
Units::UpdateTunneler 0x0054E6C0 #516 59.6% / 56.3% -> 100.0% / 100.0% checkIfCitizenUnitIsAliveBasedOnState, hasUnitReachedDestination
Units::UpdateWheatFarmer 0x005521D0 #516 37.7% / 35.9% -> 100.0% / 100.0% IncrementAndOptionalUpdateAVValueRelated, ConsiderHavingABreakNowUnk, SetStateToFreetimeWalking, ComputeGoodsProduced, checkIfCitizenUnitIsAliveBasedOnState, hasUnitReachedDestination, changeDestinationByAmount, UpdateWorker_ConsiderTakingABreakUnk
Units::UpdateCrusaderArcher 0x0055A800 #518 65.7% / 61.3% -> 100.0% / 100.0% xyAreValid, hasUnitReachedDestination, changeDestinationByAmount
Units::UpdateCrossbowman 0x0055C7B0 #516 62.5% / 53.6% -> 100.0% / 100.0% hasUnitReachedDestination
Units::UpdateLadderman 0x00563910 #516 47.2% / 34.9% -> 100.0% / 100.0% hasUnitReachedDestination
Units::UpdateArabianArcher 0x00570400 #518 55.8% / 52.4% -> 100.0% / 100.0% hasUnitReachedDestination
Units::UpdateFireThrower 0x005769F0 #516 64.0% / 60.6% -> 100.0% / 100.0% hasUnitReachedDestination

Raw / normalised reccmp figures with the option on, from the full builds below; "before" is main ff7e56e built the same way. Normalised is main's reccmp_report.py figure, which ignores call and tail-jump targets and resolver addresses. With the option off, the default build, all twelve read 100.0% before and after.

What the entries name

With the option on, every caller and callee joined by entries ends up in one group, each group is built as one wrapper unit that #includes its members (without /GL), and the members leave the /GL list. The unit helpers that main's unit entries name are in one such group, the group that holds hasUnitReachedDestination. A /GL unit without an entry stays on the /GL list but no longer sees them, which is why the nine read 37.7% to 65.7%.

Each entry names only callees that are already members of the group that holds hasUnitReachedDestination, so the nine join that group and nothing else moves: no other function leaves the /GL list, and no other function sees a body it didn't see before. Their other /GL callees (setDestinationForUnit, moveToFreeTileNearby, acquireShootTarget, shootProjectile and the rest of their closures) stay out of the group and opaque to them, and the nine read 100.0% that way. Naming each unit's whole /GL callee closure instead would put 28 more functions in that group: with every .cpp of main as the build list, cmake/function-visibility-units.py then makes 22 wrapper units holding 178 source files, against 25 holding 141 on main (the nine units and 28 of their callees join, and three smaller groups merge in). Those 28 would leave the /GL list for callers on main that have no entry (processUnitMove, exitLadder, unitClimbing, UpdateHorseArcher_DoShooting and others).

Each caller-callee pair is measured as #491's were: the unit's file compiled with the callee files pasted in front of it, against the unit alone (quick_diff, on main ff7e56e, with the resolvers as in the setup line below). The callees tried are the group's members that the unit calls directly or through another member it calls (so indirect ones too: commitUnitLocation's two callees for UpdateTunneler, ConsiderHavingABreakNowUnk behind UpdateWorker_ConsiderTakingABreakUnk for UpdateWheatFarmer), not callees reached only through functions outside the group. A callee is named when leaving it out of that set lowers the ratio, and the named set reads what the whole set reads:

  • UpdateMother 0.5668 alone, 0.9918 with its three; UpdateChild 0.5564, 0.9993 with its four; UpdateTunneler 0.6433, 0.9897 with its two; UpdateWheatFarmer 0.4115, 0.9988 with its eight; UpdateCrusaderArcher 0.6723, 0.9869 with its three.
  • UpdateCrossbowman 0.6537, UpdateLadderman 0.4106, UpdateArabianArcher 0.5843 and UpdateFireThrower 0.6844 alone; 0.9964, 0.9938, 0.9944 and 0.9965 with hasUnitReachedDestination.
  • Not named because leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState (UpdateMother, UpdateChild, UpdateWheatFarmer), and commitUnitLocation with its callees setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs (UpdateTunneler). They are in the group anyway, through other entries.
  • The commit message gives what each named callee reads when left out. quick_diff is stricter than reccmp about register names; the real builds read each of the nine at 100.0%.

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed: the data resolvers with tools/reimplementation-control/enable_reimplemented_data.py, the function resolver of every .cpp in the build with tools/reimplementation-helper/batch/enable_local_functions.py), and sourcehold's reccmp (a86aceb03) with --resolve-wrapped-calls --ignore-security-cookie.
  • Full builds, option on: every .cpp of main but the 12 in the note below, with all function and data resolvers on, 3,025 files and 3,043 functions, 0 failures, once on this branch and once on main ff7e56e. Nothing on main reads differently: the only changes are the nine units, as in the table. Average 99.23% against 99.10%. cmake/function-visibility-units.py makes 25 wrapper units holding 150 source files (141 on main): the nine join the group that holds hasUnitReachedDestination, and no other file changes group.
  • Small builds, both modes, of this branch on main ff7e56e: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units and main's UpdatePriest with their callee closures, and every file of a function-visibility group that touches them: 485 files, 495 functions, 0 failures in both modes.
    • Option on: all twelve read 100.0% / 100.0%. Main's UpdatePriest, a /GL unit without an entry, reads 72.0% / 68.9%, as in main's builds.
    • Option off: all twelve and UpdatePriest read 100.0% / 100.0%.
  • Option off, full build: not run. CMake reads cmake/function-visibility.txt only inside if(OPENSHC_FUNCTION_VISIBILITY_UNITS) (CMakeLists.txt line 148): the file is registered as a configure dependency and handed to cmake/function-visibility-units.py there and nowhere else, so with the option off this branch builds exactly what main builds.
  • Checks: there is no .cpp or header change, so style_lint.py has nothing to check.
  • Not run in game.
  • Note: main ff7e56e still has 12 files that don't compile since Reimplement 59 TextManager and UserTextHandler functions at 100% #509's sync (renderDebugDataCurrentPlayerData, applyGateOrDrawbridgeOpenCloseChange, initializeGatePathfindingForOwner, updatePathLinkageTileMap, UpdateGateHouseLarge, UpdateGateHouseSmall, UpdateWoodGate1, findBestAttackTileByPathCost, resetTileAndClearMoat, GateOpenOrClose, ClickOpenOrCloseGate, TransformAndRenderPercentage). All the builds above left them out, with their resolvers off. This PR doesn't touch them.

Left out

Other PRs

🤖 Generated with Claude Code

…d#515, sourcehold#516 and sourcehold#518

sourcehold#515, sourcehold#516 and sourcehold#518 put twelve units on cmake/compiler-flags-gl.txt. UpdateCamel, UpdateLady and UpdateFireEater
have an entry here already and read 100.0% with OPENSHC_FUNCTION_VISIBILITY_UNITS on; the other nine have none. In
that mode the members of every group leave the /GL list, among them the helpers in the group that holds
hasUnitReachedDestination, so a /GL unit without an entry no longer sees them: the nine read 37.7% to 65.7% in main
ff7e56e's full build in that mode, the build the real builds below compare against. Each gets an entry at its
address, its callees in address order. The /GL lines stay as they are.

Each entry names only callees that are already members of the group that holds hasUnitReachedDestination, so the
nine join that group and nothing else moves: no other function leaves the /GL list, and no other function sees a
body it did not see before. The nine's other /GL callees (setDestinationForUnit, moveToFreeTileNearby,
acquireShootTarget, shootProjectile and the rest of their closures) stay opaque to them, and they read 100.0% /
100.0% that way (raw / normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and
resolver addresses). Naming each unit's whole /GL callee closure instead would put 28 more functions in that group:
with every .cpp of main as the build list, cmake/function-visibility-units.py then makes 22 wrapper units holding 178
source files, against 25 holding 141 on main (the nine units and 28 of their callees join, and three smaller groups
merge in). Those 28 would leave the /GL list for main's callers that have no entry (processUnitMove, exitLadder,
unitClimbing, UpdateHorseArcher_DoShooting and others).

Each caller-callee pair is measured as sourcehold#491's were: the unit's file compiled with the callee files pasted in front of
it, against the unit alone, quick_diff on main ff7e56e. The data resolvers were switched on with
tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list
with tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are
the group's members that the unit calls directly or through another member it calls (so indirect ones too:
commitUnitLocation's two callees for UpdateTunneler, ConsiderHavingABreakNowUnk behind
UpdateWorker_ConsiderTakingABreakUnk for UpdateWheatFarmer), not callees reached only through functions outside the
group. A callee is listed when leaving it out of that set lowers the ratio; the listed set reads what the whole set
reads. quick_diff is stricter than reccmp about register names; the real builds read each unit at 100.0%.

- UpdateMother: 0.5668 alone, 0.9918 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.7900,
  hasUnitReachedDestination 0.8918, changeDestinationByAmount 0.8994.
- UpdateChild: 0.5564 alone, 0.9993 with its 4. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.8294,
  hasUnitReachedDestination 0.9153, hasTunnelerNotFinishedDigging 0.9881, changeDestinationByAmount 0.9976.
- UpdateTunneler: 0.6433 alone, 0.9897 with its 2. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.7619,
  hasUnitReachedDestination 0.6726. commitUnitLocation and its callees setupUnitSharingCurrentTilePosition and
  setupUnitSharingTileIDs change nothing.
- UpdateWheatFarmer: 0.4115 alone, 0.9988 with its 8. Left out, IncrementAndOptionalUpdateAVValueRelated reads
  0.7775, ConsiderHavingABreakNowUnk 0.9838, SetStateToFreetimeWalking 0.9898, ComputeGoodsProduced 0.9784,
  checkIfCitizenUnitIsAliveBasedOnState 0.8193, hasUnitReachedDestination 0.9462, changeDestinationByAmount 0.9130,
  UpdateWorker_ConsiderTakingABreakUnk 0.9838.
- UpdateCrusaderArcher: 0.6723 alone, 0.9869 with its 3. Left out, xyAreValid reads 0.9709,
  hasUnitReachedDestination 0.7176, changeDestinationByAmount 0.9853.
- UpdateCrossbowman: 0.6537 alone, 0.9964 with hasUnitReachedDestination.
- UpdateLadderman: 0.4106 alone, 0.9938 with hasUnitReachedDestination.
- UpdateArabianArcher: 0.5843 alone, 0.9944 with hasUnitReachedDestination.
- UpdateFireThrower: 0.6844 alone, 0.9965 with hasUnitReachedDestination.
makeUnitStopWalkingByClearingPathProgressState, which UpdateMother, UpdateChild and UpdateWheatFarmer call, changes
nothing for any of them.

With every .cpp of main as the build list, cmake/function-visibility-units.py now makes 25 wrapper units holding
150 source files (141 before): the nine join the group that holds hasUnitReachedDestination, and no other file
changes group. CMake reads this file only with the option on, so the default build is unchanged.

Real builds of this change on main ff7e56e, BUILD_OK and 0 failures each:
- full, option on: every .cpp of main with all function and data resolvers on (the 12 files that don't compile since
  sourcehold#509's sync left out), 3,025 files and 3,043 functions, against main ff7e56e built the same way. The nine read
  100.0% / 100.0% (main: 37.7% to 65.7%); nothing else reads differently.
- small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units and
  UpdatePriest with their callee closures, and every file of a group that touches them, 485 files and 495 functions.
  All twelve read 100.0% / 100.0% in both modes; UpdatePriest, which has no entry, 100.0% off and 72.0% / 68.9% on,
  as on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gynt
gynt added this pull request to the merge queue Nov 30, 2026
Merged via the queue into sourcehold:main with commit e62246a Nov 30, 2026
5 checks passed
gynt pushed a commit to gynt/OpenSHC that referenced this pull request Dec 2, 2026
…t and UpdateMiller (sourcehold#535)

sourcehold#534 gave the nine /GL units of sourcehold#515, sourcehold#516 and sourcehold#518 that had no entry in cmake/function-visibility.txt one, and left
three for a follow-up: UpdatePeasant and UpdateMiller (sourcehold#533), and UpdatePriest, main's own unit. This adds the three,
each at its address, its callees in address order. All three are on cmake/compiler-flags-gl.txt already (UpdatePriest
was there before those PRs); that file stays as it is. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, the members of every
group leave the /GL list, among them the helpers in the group that holds hasUnitReachedDestination, so a /GL unit
without an entry no longer sees them: in main e62246a's full build in that mode, the build the real builds below
compare against, UpdatePriest reads 72.0% / 68.9%, UpdatePeasant 49.3% / 48.7% and UpdateMiller 51.7% / 46.2% (raw /
normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and resolver addresses).

UpdatePriest's entry names only callees that are already members of the group that holds hasUnitReachedDestination, as
sourcehold#534's do. UpdatePeasant's and UpdateMiller's name members of that group and, each, one more /GL callee that is not in
it: getDestination2EqualsGivenCoordinates for UpdatePeasant and standUpIfSeated for UpdateMiller. With the members
alone they read 96.0% / 87.1% and 96.5% / 93.0% in an earlier full build of this branch with the option on (below).
With that callee they read 100.0%, so it joins the group, and with the option on, CMake takes five more files off the
/GL list: the three units, getDestination2EqualsGivenCoordinates and standUpIfSeated. Nothing else moves:
getDestination2EqualsGivenCoordinates is called by UpdatePeasant only, and standUpIfSeated by UpdateMiller,
standUpAllTribeUnits and updatePeasantSeatingAtBuilding (neither of the last two is on the /GL list or has an entry, so
neither saw its body before or sees it now). No other function sees a body it did not see before. The three units'
other /GL callees (setDestinationForUnit, resetUnitMovementState, clearHiddenFlagAndUpdatePosition,
setWorkplaceBuildingEntryAsTarget, selectNewBlessingTarget, setUnitFacingDirectionTowardsTarget and the rest of their
closures) stay opaque to them.

Each caller-callee pair is measured as sourcehold#491's and sourcehold#534's were: the unit's file compiled with the callee files pasted in
front of it, against the unit alone, quick_diff on main e62246a, with the data resolvers switched on by
tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list
by tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are the
group's members that the unit calls directly or through another member it calls (commitUnitLocation's callee
setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs, included), not callees reached only
through functions outside the group; and, for UpdatePeasant and UpdateMiller, each /GL callee outside the group that
they call, one at a time on top of the named members, pasted without its own callees unless it says "with its callees".
A callee is listed when leaving it out of the set lowers the ratio; the listed set reads what the whole set reads.
quick_diff is stricter than reccmp about register names; the real builds read the units at 100.0%.

- UpdatePriest: 0.7534 alone, 0.9986 with its 5. Left out, makeUnitStopWalkingByClearingPathProgressState reads
  0.9891, IncrementAndOptionalUpdateAVValueRelated 0.8859, checkIfCitizenUnitIsAliveBasedOnState 0.9510,
  hasUnitReachedDestination 0.9680, changeDestinationByAmount 0.9850. commitUnitLocation, its callee
  setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs change nothing.
- UpdatePeasant: 0.5329 alone, 0.9941 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.5880,
  getDestination2EqualsGivenCoordinates 0.9725, hasUnitReachedDestination 0.9684. Outside the group, on top of the two
  members, clearHiddenFlagAndUpdatePosition (with its callees) and setDestinationForUnit change nothing.
- UpdateMiller: 0.5531 alone, 0.9973 with its 13. Left out, getBuildingResourceAmountByUid reads 0.9722,
  setupUnitSharingTileIDs 0.9947, standUpIfSeated 0.9913, sitDownIfStanding 0.9953,
  IncrementAndOptionalUpdateAVValueRelated 0.8442, ConsiderHavingABreakNowUnk 0.9914, SetStateToFreetimeWalking
  0.9707, ComputeGoodsProduced 0.9661, checkIfCitizenUnitIsAliveBasedOnState 0.8008, hasUnitReachedDestination 0.9593,
  setupUnitSharingCurrentTilePosition 0.9947, UpdateWorker_ConsiderTakingABreakUnk 0.9914, commitUnitLocation 0.9947.
  makeUnitStopWalkingByClearingPathProgressState changes nothing. Outside the group, on top of the twelve members,
  resetUnitMovementState (with its callees), setDestinationForUnit, setWorkplaceBuildingEntryAsTarget,
  addResourceToStockpile, buildingIsAccessible, updateBuildingSignpostCounter and
  getStorageBuildingForResourceTypeAndAmount change nothing; the last four are members of other groups, so with the
  option on they are off the /GL list already, and naming one would merge two groups.

With every .cpp of main as the build list, cmake/function-visibility-units.py makes 25 wrapper units holding 155
source files (150 before): the three units and the two callees join the group that holds hasUnitReachedDestination, and
no other file changes group. CMake reads this file only with the option on, so the default build is unchanged.

Real builds on main e62246a, BUILD_OK and 0 failures each:
- full, option on: every .cpp of main with all function and data resolvers on (the 3 files that don't compile there
  left out: findBestAttackTileByPathCost, resetTileAndClearMoat, TransformAndRenderPercentage), 3,036 files and 3,054
  functions, against main e62246a built the same way. Two full builds of the branch's side: one with the three
  entries without getDestination2EqualsGivenCoordinates and standUpIfSeated (UpdatePriest's as it is now), which reads
  UpdatePeasant 96.0% / 87.1%, UpdateMiller 96.5% / 93.0% and UpdatePriest 100.0% / 100.0%; and this change, which
  reads the three 100.0% / 100.0%. Against main nothing else reads differently in either.
- small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units of
  sourcehold#515, sourcehold#516 and sourcehold#518 (nine in sourcehold#534, three with an entry before it) and these three with their callee closures,
  standUpAllTribeUnits and updatePeasantSeatingAtBuilding, and every file of a group that touches them, 494 files and
  504 functions. All fifteen units read 100.0% / 100.0% in both modes. UpdateFireBallistaBuilding: with the option
  off, where this file is not read, 100.0% / 100.0% with the 494 files and 99.6% / 95.5% with 492 (without
  standUpAllTribeUnits and updatePeasantSeatingAtBuilding), so its reading changes with the set of files built; with
  the option on, 99.6% / 95.5% with the 494 files, and main was not built with those files and the option on, so that
  case is not settled. It reads 100.0% / 100.0% in both full builds, this change's and main's.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants